package com.zhengtoudai.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhengtoudai.R;
import com.zhengtoudai.ui.bean.Repossessed;
import com.zhengtoudai.view.recyclerview.RecyclerViewAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 我的投资--投资中适配器
 */

public class MyRedeemableAdapter extends RecyclerViewAdapter<MyRedeemableAdapter.ViewHolder,Repossessed.ListEntity> {
    @Override
    public MyRedeemableAdapter.ViewHolder mOnCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.list_item_my_redeemable, parent, false);
        return new MyRedeemableAdapter.ViewHolder(view);
    }

    @Override
    public void mOnBindViewHolder(MyRedeemableAdapter.ViewHolder holder, int position) {
        holder.mTvTitle.setText(data.get(position).getBorrowTitle());
        holder.mTvE.setText(data.get(position).getTenderSum() + "元");
        holder.mTvShi.setText(data.get(position).getTenderAddtime());
        holder.mTvLv.setText(data.get(position).getAnnualInterestRate() + "%");
        holder.mTvQi.setText(data.get(position).getBorrowTimeLimit() + data.get(position).getIsDay());
        String notes = null;
        if (data.get(position).getRepaymentStyle() == 1) {
            notes = "一次性还款";
        } else if (data.get(position).getRepaymentStyle() == 2) {
            notes = "按月分期";
        } else if (data.get(position).getRepaymentStyle() == 3) {
            notes = "每月还息到期还本";
        } else if (data.get(position).getRepaymentStyle() == 4) {
            notes = "每季还息到期还本";
        } else if (data.get(position).getRepaymentStyle() == 5) {
            notes = "按季分期";
        }
        holder.mTvLowerRight.setText(notes);
    }


    static class ViewHolder extends RecyclerView.ViewHolder  {
        @Bind(R.id.tv_title)
        TextView mTvTitle;
        @Bind(R.id.tv_e)
        TextView mTvE;
        @Bind(R.id.tv_shi)
        TextView mTvShi;
        @Bind(R.id.tv_lower_right)
        TextView mTvLowerRight;
        @Bind(R.id.tv_lv)
        TextView mTvLv;
        @Bind(R.id.tv_qi)
        TextView mTvQi;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
